package com.magicsoft.share.ui.my;

import android.content.Intent;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.TextView;

import com.magicsoft.share.R;
import com.magicsoft.share.base.BaseActivity;
import com.magicsoft.share.bean.my.UserInfo;
import com.magicsoft.share.constant.Url;
import com.magicsoft.share.presenter.my.VipPresenter;
import com.magicsoft.share.ui.main.H5Activity;
import com.magicsoft.share.view.my.IVipView;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * @author fujie
 */
public class VipActivity extends BaseActivity<IVipView, VipPresenter> implements IVipView {


    @BindView(R.id.view_top)
    View viewTop;
    @BindView(R.id.ibtn_left)
    ImageButton ibtnLeft;
    @BindView(R.id.tv_title)
    TextView tvTitle;
    @BindView(R.id.tv_num)
    TextView tvNum;
    @BindView(R.id.btn_recommend)
    Button btnRecommend;
    @BindView(R.id.btn_rule)
    Button btnRule;
    @BindView(R.id.btn_explain)
    Button btnExplain;
    private UserInfo userInfo;

    @Override
    public VipPresenter initPresenter() {
        return new VipPresenter();
    }

    @Override
    public int getLayoutId() {
        return R.layout.activity_vip;
    }

    @Override
    public void initData() {

        userInfo = ((UserInfo) getIntent().getSerializableExtra("userInfo"));
    }

    @Override
    public void initView() {
        if (null != userInfo) {
            tvNum.setText(userInfo.getAccumulated_income() + "");
        }

    }

    @Override
    public void requestData() {

        mPresenter.userDetail();
    }


    @OnClick({R.id.ibtn_left, R.id.btn_recommend, R.id.btn_rule, R.id.btn_explain, R.id.lin_back})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.ibtn_left:
                finish();
                break;
            case R.id.btn_recommend:
                Intent intent = new Intent(this, RecommendActivity.class);
                startActivity(intent);
                break;
            case R.id.btn_rule:


                Intent intent1 = new Intent(this, H5Activity.class);
                intent1.putExtra("urlStr", Url.BASE_URL + "api/open/platform/membershipRules");
                intent1.putExtra("titleStr", "会员规则");
                startActivity(intent1);
                break;
            case R.id.btn_explain:
                Intent intent2 = new Intent(this, H5Activity.class);
                intent2.putExtra("urlStr", Url.BASE_URL + "api/open/platform/invitationToNote");
                intent2.putExtra("titleStr", "邀请说明");
                startActivity(intent2);
                break;
            case R.id.lin_back:
                finish();
                break;
        }
    }

    @Override
    public void userDetailSuccess(UserInfo userInfo) {
        tvNum.setText(userInfo.getAccumulated_income() + "");
    }
}
